#include <stdio.h>

int main(){
	int a[10] = {8,3,5,9,7,2,10,12,11,13}; //定义原数组
	int b[10] = {0};  //定义存储素数的数组
	int N = 10;
	int i = 0;
	int j = 0;
	for (i = 0; i < N; i++){  //输出原数组
		printf("%d ",a[i]);
	}
	printf("\n");

	int count = 0;
	int tmp = 0;
	for (i = 0; i < N; i++){  //a[10]遍历
		for(j = 2; j < a[i]; j++){  //数组a[10]对2~a[i]-1取余，若是合数，则tmp = 1，若是素数，则tmp = 0无变化
			if(a[i] % j == 0){tmp = 1;}  		
		}
		if(tmp == 1){tmp = 0;}   //对tmp判断，如是素数，则存到b[]数组
		else{
			b[count] = a[i];
			count++;
		}
	}

	N = count;   //对只有素数的b[]数组进行插入排序
	for (i = 1; i < N; i++){
		tmp = b[i];
		for (j = i - 1; j >= 0; j--){
			if(tmp < b[j]){
				b[j+1] = b[j];
			}else{break;}
		}
		b[j+1] = tmp;
	}

	for (i = 0; i < count; i++){   //输出排好序的b[]数组
		printf("%d ",b[i]);
	}
	printf("\n");
	return 0;
}
